Ext.define('DragonApp.view.property.SelectedGrid', {
    extend: 'Ext.grid.Panel',

    alias: ['widget.propertyselected'],

    requires: [
        'DragonApp.store.SelectedProp'
    ],
    selModel: 'cellmodel',

    plugins: {
        ptype: 'cellediting',
        clicksToEdit: 1
    },
    viewConfig: {
        plugins: {
            ptype: 'gridviewdragdrop',
            dragText: '拖拽图像排序'
        },
        markDirty: true
    },

    columns: [
        { xtype: 'rownumberer', text: '序号', width: 70, align: 'center' },
        { text: '道具/佣兵ID', dataIndex: 'id', flex: 1, align: 'center', hideable: false },
        { text: '道具名称', dataIndex: 'name', flex: 1, align: 'center', hideable: false },
        {
            text: '道具数量',
            dataIndex: 'num',
            align: 'center',
            xtype: 'numbercolumn',
            width: 100,
            format: '0',
            editor: {
                xtype: 'numberfield',
                minValue: 1,
                maxValue: 999999,
                decimalPrecision: 0,
                selectOnFocus: true,
                allowBlank: false
            },
            hideable: false
        },
        {
            text: '操作',
            xtype: 'widgetcolumn',
            width: 120,
            itemId: 'delete',
            align: 'center',
            sortable: false,
            hideable: false,
            menuDisabled: true,
            widget: {
                xtype: 'button',
                text: '删除',
                width: 80,
                iconCls: "x-fa fa-minus-circle",
                tooltip: '删除道具',
                handler: function(button, event) {

                    var grid = Ext.ComponentQuery.query('propertyselected')[0];
                    var selectedstore = Ext.data.StoreManager.lookup('selected_prop');

                    var rowIndex = button.up('gridview').indexOf(button.el.up('table'));
                    selectedstore.removeAt(rowIndex);
                }
            },
            itemId: 'delete'
        }
    ],
    store: {
        type: 'selectedprop',
        storeId: 'selected_prop'
    }
});